package cn.edu.scau.cmi.wangzm.abstractfactory;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class FactoryController {
	@FXML
    private Button button1;
	@FXML
    private Button button2;
	@FXML
    private Button button3;
    @FXML
    private TextArea outputArea;
    @FXML
    private TextField inputField;
    private AbstractFactory factory=null;
    private ConsumerSelect product=null;
    @FXML
    void handleOk1(ActionEvent event) {
    	if(inputField.getText().isEmpty()) {outputArea.appendText("请选择品牌后操作!!!\n");}
    	else {
    		if(inputField.getText().equals("1")) {
    			factory=new WensFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：温氏牛肉\n");
    		}
    		else if(inputField.getText().equals("2")) {
    			factory=new TianBangFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：天邦牛肉\n");
    		}
    		else if(inputField.getText().equals("3")) {
    			factory=new AonongFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：傲农牛肉\n");
    		}
    		else {outputArea.appendText("请选择正确序号!!!\n");}
    	}

    }
    @FXML
    void handleOk2(ActionEvent event) {
    	if(inputField.getText().isEmpty()) {outputArea.appendText("请选择品牌后操作!!!\n");}
    	else {
    		if(inputField.getText().equals("1")) {
    			factory=new WensFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：温氏猪肉\n");
    		}
    		else if(inputField.getText().equals("2")) {
    			factory=new TianBangFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：天邦猪肉\n");
    		}
    		else if(inputField.getText().equals("3")) {
    			factory=new AonongFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：傲农猪肉\n");
    		}
    		else {outputArea.appendText("请选择正确序号!!!\n");}
    	}
    }
    @FXML
    void handleOk3(ActionEvent event) {
    	if(inputField.getText().isEmpty()) {outputArea.appendText("请选择品牌后操作!!!\n");}
    	else {
    		if(inputField.getText().equals("1")) {
    			factory=new WensFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：温氏鸡肉\n");
    		}
    		else if(inputField.getText().equals("2")) {
    			factory=new TianBangFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：天邦鸡肉\n");
    		}
    		else if(inputField.getText().equals("3")) {
    			factory=new AonongFactory();
    			product=factory.makeBeef();
    			outputArea.appendText("成功购买：傲农鸡肉\n");
    		}
    		else {outputArea.appendText("请选择正确序号!!!\n");}
    	}
    }
}
